package com.tuweiya.study.springmvc002.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import springfox.documentation.annotations.ApiIgnore;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

/**
 * @Author: Mr_tu
 * @Date: Create in 16:20 2018/6/6
 * @Description: 测试controller
 */
@Controller
@RequestMapping("/mvc")
@Api(tags = "MvcController", description = "测试接口")
public class MvcController {

    @GetMapping("/hello")
    @ApiIgnore
    public String hello(HttpServletRequest request) {
        HttpSession httpSession = request.getSession();
        httpSession.setAttribute("name", "Mr_tu");
        return "hello";
    }

    @ApiOperation(value = "返回")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "name", value = "姓名", required = true, paramType = "query")
    })
    @GetMapping("/hello1")
    public String hello(HttpServletRequest request, String name) {
        HttpSession httpSession = request.getSession();
        httpSession.setAttribute("name", name);
        return "hello";
    }

    @GetMapping("/test")
    @ResponseBody
    public String test() {
        return "Hello World.";
    }


}
